from pydantic import BaseModel
from typing import Optional, List
from app.schemas.base import BaseResp
from datetime import datetime

class WPTradingPairBase(BaseModel):
    """WaveUp交易对"""
    productPairId: str = ""
    productPairName: str = ""
    tradeStatus: int = 0
    productIdA: str = ""
    productNameA: str = ""
    productImageA: str = ""
    productIdB: str = ""
    productNameB: str = ""
    productImageB: str = ""
    lockAmountA: float = 0.0
    lockAmountB: float = 0.0
    lockAmountK: float = 0.0
    platformFeeRate: float = 0.0
    poolFeeRate: float = 0.0
    slipPageRange: str = ""

class WPTradingPairListQueryReq(BaseModel):
    """查询WaveUp交易对列表请求"""
    pageNo: int = 1
    pageSize: int = 10
    # 交易状态列表 0待投票, 1投票中, 2待开放, 3投票失败, 4开放中, 5已停牌
    tradeStatusList: Optional[List[int]] = None

class WPTradingPairCreate(WPTradingPairBase):
    """创建WaveUp交易对请求"""
    pass

class WPTradingPairUpdate(BaseModel):
    """更新WaveUp交易对请求"""
    id: int = 0
    lockAmountA: float = 0.0
    lockAmountB: float = 0.0
    lockAmountK: float = 0.0
    platformFeeRate: float = 0.0
    poolFeeRate: float = 0.0
    slipPageRange: str = ""

class WPTradingPairOut(WPTradingPairBase):
    """WaveUp交易对"""
    archiveIdA: int = 0
    archiveIdB: int = 0
    platformIdA: int = 0
    platformIdB: int = 0

class ProductSwapReq(BaseModel):
    """WaveUp产品兑换项"""
    productPairId: str = ""
    fromProductId: str = ""
    fromAmount: str = ""
    toAmount: str = ""
    slippage: str = "0"
    profitAmount: float = 0.0
    orderNo: str = ""

# 藏品兑换(请求WaveUp接口参数)
class WPProductSwapReq(BaseModel):
    """WaveUp藏品对交易"""
    accessToken: str = ""
    productPairId: str = ""
    fromProductId: str = ""
    fromAmount: str = ""
    toAmount: str = ""
    slippage: str = "0"
    swapOrderNo: str = ""

class PreProductSwapReq(BaseModel):
    """WaveUp藏品对交易预检查请求"""
    productPairId: str = ""

class PreProductSwapResp(BaseResp):
    """WaveUp藏品对交易预检查返回数据"""
    orderNo: str = ""
    expireAt: datetime = None